package com.zbcz.crm.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Window
import android.widget.ImageView
import android.widget.TextView
import com.zbcz.crm.R

class CustomDialog(context: Context) : Dialog(context) {

    private var isSuccess: Boolean = true // 默认为成功状态
    private lateinit var imageView: ImageView
    private lateinit var textView: TextView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        setContentView(R.layout.dialog_layout)

        imageView = findViewById(R.id.iv_submit_image)
        textView = findViewById(R.id.tv_status)

        updateStatus()
    }

    // 设置状态为成功
    fun setSuccess() {
        isSuccess = true
        updateStatus()
    }

    // 设置状态为失败
    fun setFailure() {
        isSuccess = false
        updateStatus()
    }

    // 更新状态
    private fun updateStatus() {
        if (isSuccess) {
            imageView.setImageResource(R.drawable.success_icon) // 替换成成功状态的图片资源
            textView.text = "提交成功" // 设置成功状态的文本
        } else {
            imageView.setImageResource(R.drawable.failed_icon) // 替换成失败状态的图片资源
            textView.text = "提交失败" // 设置失败状态的文本
        }
    }
}
